<html>
<head><meta charset="utf-8"><title>refactor CandidateKind · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactor.20CandidateKind.html">refactor CandidateKind</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="198372555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactor%20CandidateKind/near/198372555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactor.20CandidateKind.html#198372555">(May 21 2020 at 20:26)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/70705#discussion_r416685289">https://github.com/rust-lang/rust/pull/70705#discussion_r416685289</a><br>
<span class="user-mention" data-user-id="116009">@nikomatsakis</span></p>
<p>I looked at the current implementation and think I am now able to actually have some kind of opinion here <span aria-label="laughing" class="emoji emoji-1f606" role="img" title="laughing">:laughing:</span></p>



<a name="198372610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactor%20CandidateKind/near/198372610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactor.20CandidateKind.html#198372610">(May 21 2020 at 20:26)</a>:</h4>
<p>There are currently some things related to your comment which I would also like to refactor while I am at it.</p>
<p><a href="https://github.com/rust-lang/rust/blob/148c125b1bf20674e8d0c55c21b3433a6d465b07/src/librustc_trait_selection/traits/select.rs#L1986"><code>candidate_should_be_dropped_in_favor_of</code></a>  feels really unintuitive to me.<br>
It is probably a good idea to express this in a positive way, i.e. something like <code>prioritize_candidate_over</code>.</p>



<a name="198372664"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactor%20CandidateKind/near/198372664" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactor.20CandidateKind.html#198372664">(May 21 2020 at 20:27)</a>:</h4>
<blockquote>
<p>Of these, BuiltinCandidate { has_nested: false } is the "odd one out", because it applies not only to a specific trait, but to a specific self type for that trait. Are we actually exposing "movable generators" anywhere in the language? I don't think so, and I don't know that we have any real plans to do so either, right? I wonder if we should simplify things by removing them.</p>
</blockquote>
<p>We currently  use <code>BuiltinCandidate { has_nested: false }</code>  for actual builtin types which do not add any obligations and use this info to treat them in a special way during winnowing. I don't think we can remove that variant.</p>



<a name="198375341"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactor%20CandidateKind/near/198375341" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactor.20CandidateKind.html#198375341">(May 21 2020 at 20:48)</a>:</h4>
<p>We currently recompute builtin conditions in <code>confirm_builtin_candidate</code>, which is not ideal.</p>



<a name="198375927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactor%20CandidateKind/near/198375927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactor.20CandidateKind.html#198375927">(May 21 2020 at 20:52)</a>:</h4>
<p>I still need some info on what you had in mind here, as I don't yet see how to best cleanup <code>CandidateKind</code>.</p>



<a name="198470602"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactor%20CandidateKind/near/198470602" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactor.20CandidateKind.html#198470602">(May 22 2020 at 17:31)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/144729-wg-traits/topic/refactor.20CandidateKind/near/198372610">said</a>:</p>
<blockquote>
<p>There are currently some things related to your comment which I would also like to refactor while I am at it.</p>
<p><a href="https://github.com/rust-lang/rust/blob/148c125b1bf20674e8d0c55c21b3433a6d465b07/src/librustc_trait_selection/traits/select.rs#L1986"><code>candidate_should_be_dropped_in_favor_of</code></a>  feels really unintuitive to me.<br>
It is probably a good idea to express this in a positive way, i.e. something like <code>prioritize_candidate_over</code>.</p>
</blockquote>
<p><span class="user-mention" data-user-id="216206">@lcnr</span> you are referring specifically to the name here?</p>



<a name="198470648"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactor%20CandidateKind/near/198470648" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactor.20CandidateKind.html#198470648">(May 22 2020 at 17:32)</a>:</h4>
<p>If so, I have no objection</p>



<a name="198470726"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactor%20CandidateKind/near/198470726" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactor.20CandidateKind.html#198470726">(May 22 2020 at 17:32)</a>:</h4>
<p>both the name and the boolean</p>



<a name="198470748"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactor%20CandidateKind/near/198470748" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactor.20CandidateKind.html#198470748">(May 22 2020 at 17:32)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/144729-wg-traits/topic/refactor.20CandidateKind/near/198372664">said</a>:</p>
<blockquote>
<p>We currently  use <code>BuiltinCandidate { has_nested: false }</code>  for actual builtin types which do not add any obligations and use this info to treat them in a special way during winnowing. I don't think we can remove that variant.</p>
</blockquote>
<p>I was proposing that we remove <em>moveable generators</em> entirely</p>



<a name="198470770"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactor%20CandidateKind/near/198470770" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lcnr <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactor.20CandidateKind.html#198470770">(May 22 2020 at 17:33)</a>:</h4>
<p>We currently return <code>true</code> if the candidate should get dropped, while I want to invert this</p>



<a name="198470780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactor%20CandidateKind/near/198470780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactor.20CandidateKind.html#198470780">(May 22 2020 at 17:33)</a>:</h4>
<p>which is somewhat orthogonal</p>



<a name="198470802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactor%20CandidateKind/near/198470802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactor.20CandidateKind.html#198470802">(May 22 2020 at 17:33)</a>:</h4>
<p>but I don't really think they're used anywhere in the "stable" language</p>



<a name="198470836"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactor%20CandidateKind/near/198470836" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactor.20CandidateKind.html#198470836">(May 22 2020 at 17:33)</a>:</h4>
<p>nor do I think we have any plans to use them</p>



<a name="198470865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactor%20CandidateKind/near/198470865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactor.20CandidateKind.html#198470865">(May 22 2020 at 17:33)</a>:</h4>
<p><span class="user-mention" data-user-id="127859">@Taylor Cramer</span> may have some idea if there was any reason we might use a moveable generator</p>



<a name="198470959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactor%20CandidateKind/near/198470959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactor.20CandidateKind.html#198470959">(May 22 2020 at 17:34)</a>:</h4>
<p>Aww :(</p>



<a name="198470995"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactor%20CandidateKind/near/198470995" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactor.20CandidateKind.html#198470995">(May 22 2020 at 17:34)</a>:</h4>
<p>(Not that I use them, I just think they're cool :D)</p>



<a name="198471020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactor%20CandidateKind/near/198471020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactor.20CandidateKind.html#198471020">(May 22 2020 at 17:35)</a>:</h4>
<p>:)</p>



<a name="198471092"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactor%20CandidateKind/near/198471092" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactor.20CandidateKind.html#198471092">(May 22 2020 at 17:35)</a>:</h4>
<p><span class="user-mention silent" data-user-id="216206">lcnr</span> <a href="#narrow/stream/144729-wg-traits/topic/refactor.20CandidateKind/near/198470770">said</a>:</p>
<blockquote>
<p>We currently return <code>true</code> if the candidate should get dropped, while I want to invert this</p>
</blockquote>
<p>yeah I mean that's fine</p>



<a name="198471179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/refactor%20CandidateKind/near/198471179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/refactor.20CandidateKind.html#198471179">(May 22 2020 at 17:36)</a>:</h4>
<p>I guess I better re-read my own comment, anyhow</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>